package com.atguigu.lease.common.sms;

import com.aliyun.teaopenapi.models.Config;
import com.aliyun.dysmsapi20170525.Client;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@EnableConfigurationProperties(SmsPropertiesClass.class)
@Configuration
public class AliyunSmsConfiguration {

    @Autowired
    private SmsPropertiesClass smsPropertiesClass;
    @Bean
    public Client client() throws Exception {
        Config config = new Config();
        config.setAccessKeyId(smsPropertiesClass.getAccessKeyId());
        config.setAccessKeySecret(smsPropertiesClass.getAccessKeySecret());
        config.setEndpoint(smsPropertiesClass.getEndPoint());
        return  new Client(config);
    }
}
